<?php
/***************************************************************
*  Copyright notice
*
*  (c) 2007 Dmitry Dulepov (dmitry@typo3.org)
*  All rights reserved
*
*  This script is part of the TYPO3 project. The TYPO3 project is
*  free software; you can redistribute it and/or modify
*  it under the terms of the GNU General Public License as published by
*  the Free Software Foundation; either version 2 of the License, or
*  (at your option) any later version.
*
*  The GNU General Public License can be found at
*  http://www.gnu.org/copyleft/gpl.html.
*
*  This script is distributed in the hope that it will be useful,
*  but WITHOUT ANY WARRANTY; without even the implied warranty of
*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
*  GNU General Public License for more details.
*
*  This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
/**
 * Hooks to tt_news.
 *
 * $Id: class.tx_ratings_ttnews.php 8066 2008-01-28 12:38:14Z liels_bugs $
 */
/**
 * [CLASS/FUNCTION INDEX of SCRIPT]
 *
 *
 *
 *   52: class tx_ratings_ttnews
 *   60:     public function __construct()
 *   73:     function extraItemMarkerProcessor($markerArray, $row, $lConf, &$pObj)
 *
 * TOTAL FUNCTIONS: 2
 * (This index is automatically created/updated by the extension "extdeveval")
 *
 */


/**
 * This clas provides hook to tt_news to add extra markers.
 *
 * @author	Dmitry Dulepov <dmitry@typo3.org>
 * @package TYPO3
 * @subpackage comments
 */
class tx_fenews_ttnews {
	/**
	 * Processes comments-specific markers for tt_news
	 *
	 * @param	array		$markerArray	Array with merkers
	 * @param	array		$row	tt_news record
	 * @param	array		$lConf	Configuration array for current tt_news view
	 * @param	tx_ttnews	$pObj	Reference to parent object
	 * @return	array		Modified marker array
	 */
	public function extraItemMarkerProcessor(array &$markerArray, array &$row, &$lConf, &$pObj) {
		/* @var $pObj tx_ttnews */

		//print_r($markerArray);exit;
		
		
		if($lConf['dont_access']==1)
		{
			if(stristr($lConf['dont_access_pid'],',')) $check_pid=explode(',',$lConf['dont_access_pid']);
			else $check_pid=$lConf['dont_access_pid'];
			if(in_array($row['pid'],$check_pid)) 
			{
				header('Location: http://'.$_SERVER['SERVER_NAME']);
				exit;
			}
		}
		
		$markerArray['###TAGS###']=$markerArray['###USER###']=$markerArray['###USER_LINK###']='';
		$markerArray['###NEWS_CATEGORY_CLASS###']=strtolower(str_replace(array(','),array(''),$markerArray['###NEWS_CATEGORY###']));
		$charset = "UTF-8";
		$markerArray['###NEWS_CATEGORY_CLASS###'] = iconv($charset, "ASCII//IGNORE", $markerArray['###NEWS_CATEGORY_CLASS###'] );
		if ($row['tx_mtfenews_user']>0 && $lConf['set_user_pid']!='') {

			$cObj = t3lib_div::makeInstance('tslib_cObj');
			$conf['includeLibs'] = 'EXT:mt_fenews/pi2/class.tx_mtfenews_pi2.php';
			$conf['user'] = $row['tx_mtfenews_user'];
			$conf['userFunc']='tx_mtfenews_pi2->show_user';
			$conf['pid']=$lConf['set_user_pid'];
			
			/* @var $cObj tslib_cObj */
			$cObj->start(array());

			$markerArray['###USER###'] = $cObj->cObjGetSingle('USER_INT', $conf);
			$conf['userFunc']='tx_mtfenews_pi2->show_user_link';
			$markerArray['###USER_LINK###'] = $cObj->cObjGetSingle('USER_INT', $conf);

		}
		
		if ($row['keywords']!='') {
			
			$cObj = t3lib_div::makeInstance('tslib_cObj');
			
			$conf['includeLibs'] = 'EXT:mt_fenews/pi2/class.tx_mtfenews_pi2.php';
			$conf['userFunc']='tx_mtfenews_pi2->show_tag';
			$conf['tag']=$row['keywords'];
			$conf['tag_pid']=$lConf['tag_pid'];
			$conf['tag_separation']=$lConf['tag_separation'];
			$markerArray['###TAGS###']=$cObj->cObjGetSingle('USER_INT', $conf);
		}else $markerArray['###TAGS###']=$lConf['tag_brak'];
		
		return $markerArray;
	}
}

if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/ratings/class.tx_ratings_ttnews.php']) {
	include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/ratings/class.tx_ratings_ttnews.php']);
}

?>